#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s, t;
	getline(cin, s);

	for(auto i:s)
		if(('0' <= i && i <= '9') || ('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z'))
			t += i;
	
	cout<<t<<endl;
	
	for(auto &i:t)
		if('A' <= i && i <= 'Z')
			i += 'a'-'A';
	
	vector<int> vec;
	for(auto i:t)
	{
		if(i <= '9')
			vec.emplace_back(i-'0');
		else
			vec.emplace_back(i-'a'+10);
	}
	int cnt = 1;
	int ans = 0;
	for(int i = vec.size()-1;i >= 0;i--)
	{
		ans += vec[i]*cnt;
		cnt *= 16;
	}
	cout<<ans;
	return 0;
}

